<template>
  <div class="ConfimeOrder-box">
    <div
      class="ConfimeOrder-top cl4d fs16 fw500"
      v-if="ticket && reservedate && period"
    >
      <span class="pr10">{{ ticket.cnName }}</span>
      <span class="pr10"> {{ period.reservedate }}</span>
      <span class="pr10">{{ week[period.week] }}</span>
      <span class="pr10">{{ period.starttime.slice(-8, -3) }}</span>
      <span class="pr10"> x {{ total }}</span>
    </div>
    <div class="added-person flex">
      <div
        class="added-person-item flex jcs alc"
        v-for="item in trueInfo"
        :key="item.id"
      >
        <div>
          <p class="per-name">{{ item.realname }}</p>
          <p class="p-number">{{getCardType(item.certificateType)}} {{ item.certificateNo }}</p>
        </div>
      </div>
    </div>
    <div class="payway-box mt27">
      <div class="payway-box-title cl3 fw600 fs15">支付方式</div>
      <div class="flex alc">
        <div
          class="pay-way-item-b pt10 mr10"
          :class="{
            'cur-item': payway.gatewayCode === item.gatewayCode,
          }"
          @click="setPay(item)"
          v-for="item in payList"
          :key="item.gatewayCode"
        >
          <div class="pay-way-item">
            <img
              v-if="item.gatewayCode === 'aliwapPay:fastPay'"
              class="pay-way-item-img"
              src="../../assets/ali.png"
              alt=""
            />
            <img
              v-else-if="item.gatewayCode === 'wxAppPay'"
              class="pay-way-item-img"
              src="../../assets/6.png"
              alt=""
            />
            <span>{{ item.gatewayName }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
import { week } from '@/const/cardType'
export default {
  name: 'ConfimeOrder',
  computed: {
    ...mapState('ticketinfo', [
      'ticket',
      'reservedate',
      'period',
      'total',
      'trueInfo',
      'payway',
      'payList'
    ])
  },
  methods: {
    ...mapMutations('ticketinfo', ['ticketinfo', 'setPayway']),
    setPay (item) {
      console.log(item)
      this.setPayway({
        gatewayCode: item.gatewayCode, // 支付网关
        merchantCode: item.merchantCode, // 支付渠道
        paybank: item.paybank,
        gatewayName: item.gatewayName
        // ...item
      })
    }
  },
  data () {
    return {
      week
    }
  }
}
</script>

<style scoped lang="less">
.ConfimeOrder-box {
  .added-person {
    flex-wrap: wrap;
    margin-top: 10px;
    .added-person-item {
      padding: 13px 16px 12px 20px;
      width: 286px;
      height: 64px;
      background: #ffffff;
      border: 1px solid #f4f4f4;
      margin-right: -1px;
      margin-bottom: 10px;
      img {
        width: 24px;
        cursor: pointer;
      }
      .per-name {
        font-size: 14px;
        font-weight: 500;
        color: #4d4d4d;
        line-height: 20px;
        margin-bottom: 2px;
      }
      .p-number {
        font-size: 12px;
        font-weight: 400;
        color: #999999;
        line-height: 17px;
      }
    }
  }
  .pay-way-item-b {
    .pay-way-item {
      width: 158px;
      height: 64px;
      border-radius: 2px;
      border: 1px solid #ccc;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #666666;
      display: flex;
      align-items: center;
      cursor: pointer;
      justify-content: center;
      .pay-way-item-img {
        width: 24px;
        height: 24px;
        margin-right: 8px;
      }
    }
  }
  .cur-item {
    .pay-way-item {
      border: 1px solid #009769;
      background: rgba(0, 151, 105, 0.1);
    }
  }
}
</style>
